package com.music.biz.imp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.music.biz.UserBiz;
import com.music.dao.UserDao;
import com.music.entity.User;

@Service("userBiz")
public class UserBizImpl implements UserBiz{

	@Autowired
	private UserDao dao;
	
	public List<User> getAll() {
		// TODO Auto-generated method stub
		return dao.getAll();
	}

	public User fetchUserByEmail(String email) {
		// TODO Auto-generated method stub
		return dao.fetchUserByEmail(email);
	}

	public List<User> getUsers(int roleId) {
		// TODO Auto-generated method stub
		return dao.getUsers(roleId);
	}

	public User checkLogin(String userName, String password) {
		// TODO Auto-generated method stub
		return dao.checkLogin(userName, password);
	}

	public User fetchByUsername(String username) {
		// TODO Auto-generated method stub
		return dao.fetchByUsername(username);
	}

	@Transactional(propagation=Propagation.REQUIRED)
	public void register(User user) {
		dao.register(user);
		
	}

	@Transactional(propagation=Propagation.REQUIRED)
	public void update(User user) {
		dao.update(user);
		
	}

	@Transactional(propagation=Propagation.REQUIRED)
	public void delete(int id) {
		dao.delete(id);
	}

	

	public User getUserById(int id) {
		// TODO Auto-generated method stub
		return dao.getUserById(id);
	}

	@Override
	public List<User> checkUsername(String username) {
		// TODO Auto-generated method stub
		return dao.checkUsername(username);
	}
	

}
